package com.sakura.controller;

import com.sakura.dto.EchartsThreeDTO;
import com.sakura.service.EchartsService;
import com.sakura.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author : Sakura
 * @Date : 2024/1/9 15:41
 * @Description : TODO Echarts模块
 */
@Api(value = "/api/echarts", tags = {"Echarts模块"})
@RestController
@RequestMapping("/api/echarts")
//解决跨域问题
@CrossOrigin
public class EchartsController {

    @Autowired
    private EchartsService echartsService;

    @ApiOperation(value = "Echarts柱状图", notes = "", httpMethod = "GET")
    @GetMapping("/two")
    public R two() {
        Map<String, List> result = echartsService.getTwoData();
        return R.success(result);
    }

    @ApiOperation(value = "Echarts饼状图", notes = "", httpMethod = "GET")
    @GetMapping("/three")
    public R three() {
        List<EchartsThreeDTO> result = echartsService.getThreeData();
        return R.success(result);
    }
}
